#-*- coding: utf-8 -*-

'''
以下是對Python的參數傳遞的一些測試，
分別會對immutable物件(數字、字串、tuple)和mutable物件(List、Dictionary)做測試!
'''

def magic( num, list ):
	num  = 1000								# 重新對num作指派		
	list = [ "new list", "new object" ]		# 重新對mutable作指派
	
	print( "\n---------In magic function------------\n" )
	print "num is: " + str( num )
	print "list is: " + str( list ) + "\n"
	
number = 20
list   = [ "old list" ]

print "before calling..."
print "number is: " + str( number )
print "list is: " + str( list )
print "\n==========================================\n"


magic( number, list )
print "after calling..."
print "number is: " + str( number )
print "list is: " + str( list )


print "\n==========================================\n"

class User( object ):
	
	def __init__( self, name, age ):
		self.name = name
		self.age  = age
		
	def getName( self ):
		return self.name
		
	def getAge( self ):
		return self.age
		


def doSome( user, string ):
	user   = User( "ViVi", 21 )
	string = "Hi, I'm a girl!"
	
	return user, string
	
user   = User( "Peter", 34 )
string = "Hi, my name is Peter."

print "\nbefore call doSome... \n"
print "user name is: " + user.name + ", user age is: " + str( user.age )
print "user instance is: " + str( user )
print string

doSome( user, string )

print "\nafter call doSome... \n"
print "user name is: " + user.name + ", user age is: " + str( user.age )
print "user instance is: " + str( user )
print string


user, string = doSome( user, string )
print "\nafter call doSome and assgin\n"
print "user name is: " + user.name + ", user age is: " + str( user.age )
print "user instance is: " + str( user )


